

// Standard includes
// SystemC includes
#include <systemc>
// ArchC includes
#include "ac_tlm_protocol.H"
#include "ac_tlm_port.H"

//////////////////////////////////////////////////////////////////////////////

// using statements
using tlm::tlm_transport_if;

//////////////////////////////////////////////////////////////////////////////

//#define DEBUG

/// Namespace to isolate memory from ArchC
namespace user{

	class ac_tlm_per : public sc_module, public ac_tlm_transport_if{
	public:
		sc_export< ac_tlm_transport_if > target_export;
		void writem(const uint32_t & , const uint32_t & );
		uint32_t readm(const uint32_t & , uint32_t &  );

		
		ac_tlm_rsp transport( const ac_tlm_req &request ) {
			//cout << "Calling per" << endl;
			ac_tlm_rsp response;
			if(request.type == WRITE){
				cout << "Writing value"<<request.data << endl;
				writem(request.addr, request.data);
				response.status = SUCCESS;
			}else{
				cout << "Reading value" <<request.data<< endl;
				response.data = readm(request.addr, response.data);
				response.status = SUCCESS;
			}
			
			return response;
		}

		ac_tlm_per( sc_module_name module_name , int k = 5242880 );
		~ac_tlm_per();

	private:
		uint32_t data1, data2, saida;
		int lock;

	};//class
};//namesapce
